package com.ruoyi.web.controller.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.Effect;
import com.ruoyi.service.IEffectService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 食物功效标签管理Controller
 * 
 * @author ruoyi
 * @date 2025-05-22
 */
@RestController
@RequestMapping("/effect/effect")
public class EffectController extends BaseController
{
    @Autowired
    private IEffectService effectService;

    /**
     * 查询食物功效标签管理列表
     */
    @PreAuthorize("@ss.hasPermi('effect:effect:list')")
    @GetMapping("/list")
    public TableDataInfo list(Effect effect)
    {
        startPage();
        List<Effect> list = effectService.selectEffectList(effect);
        return getDataTable(list);
    }

    /**
     * 导出食物功效标签管理列表
     */
    @PreAuthorize("@ss.hasPermi('effect:effect:export')")
    @Log(title = "食物功效标签管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Effect effect)
    {
        List<Effect> list = effectService.selectEffectList(effect);
        ExcelUtil<Effect> util = new ExcelUtil<Effect>(Effect.class);
        util.exportExcel(response, list, "食物功效标签管理数据");
    }

    /**
     * 获取食物功效标签管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('effect:effect:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(effectService.selectEffectById(id));
    }

    /**
     * 新增食物功效标签管理
     */
    @PreAuthorize("@ss.hasPermi('effect:effect:add')")
    @Log(title = "食物功效标签管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Effect effect)
    {
        return toAjax(effectService.insertEffect(effect));
    }

    /**
     * 修改食物功效标签管理
     */
    @PreAuthorize("@ss.hasPermi('effect:effect:edit')")
    @Log(title = "食物功效标签管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Effect effect)
    {
        return toAjax(effectService.updateEffect(effect));
    }

    /**
     * 删除食物功效标签管理
     */
    @PreAuthorize("@ss.hasPermi('effect:effect:remove')")
    @Log(title = "食物功效标签管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(effectService.deleteEffectByIds(ids));
    }
}
